/*
	File:		EntityManager.h
	Course:		SGD 1303
	Author:		dmonroe
	Purpose:	CEntityManager class stores & maintains
				the game entities
*/


#pragma once


//**************************************************
// Container type: vector or list will work
#include <vector>

// Object type: forward declare for pointers
class IEntity;



//**************************************************
// CEntityManager class
//	- stores a vector of IEntity*
//	- using the interface class results in less recompiles
//	  when CEntity is modified
class CEntityManager
{
public:
	//**********************************************
	// SINGLETON!
	static CEntityManager*	GetInstance( void );
	static void				DeleteInstance( void );


	//**********************************************
	// Management Methods:
	void	AddEntity			( IEntity* ptr );
	void	RemoveEntity		( IEntity* ptr );
	void	RemoveAll			( void );

	void	UpdateAll			( float fElapsedTime );
	void	CheckAllCollisions	( void );
	void	RenderAll			( void );


private:
	//**********************************************
	// SINGLETON!
	static CEntityManager*	s_pInstance;

	CEntityManager( void );		// ctor
	~CEntityManager( void );	// dtor
	CEntityManager( const CEntityManager& );				// copy ctor
	CEntityManager& operator= ( const CEntityManager& );	// assignment op


	//**********************************************
	// Handy type names
	typedef std::vector< IEntity* >		EntityList;
	typedef EntityList::iterator		EntityListIter;


	//**********************************************
	// Container
	EntityList		m_lEntities;

	// Lock
	//	- cannot add or remove while iterating through
	//	  the container!!!
	bool			m_bIterating;
};

